package com.key.win.business.chat.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.key.win.base.mapper.KeyWinMapper;
import com.key.win.business.chat.model.ImFriend;
import com.key.win.business.chat.model.ImGroupUser;
import com.key.win.business.chat.vo.ImFriendFullVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ImFriendFullDao extends KeyWinMapper<ImFriendFullVo> {

    @Select({"SELECT * FROM ( SELECT f.id AS id, f.user_id, f.create_date, f.create_user_id, f.create_user_name, f.enable_flag, f.update_date, f.update_user_id, f.update_user_name, f.version, f.friend_Id, CASE WHEN f.`name` IS NOT NULL THEN f.`name` ELSE u.nick_name END AS `name`, f.groupId, g.`name` AS group_name, u.sign, u.head_img_url AS avatar, u.phone, u.email FROM im_friends f LEFT JOIN im_group g ON f.groupId = g.id INNER JOIN sys_user u ON f.friend_Id = u.id ) f ${ew.customSqlSegment}"})
    List<ImFriendFullVo> findMyFriend(@Param("ew") Wrapper<ImFriend> queryWrapper);
}
